Wednesday, February 15, 2006

VS2005 .NET Add-Ins Nested Menus

Writing an add-in for Visual Studio .NET always brings it's challenges. With every release of .NET, if you are an ISV, as I am, there are several challenges.

First, you have to see what features of your add-ins that Microsoft has implemented in the new IDE. When they do this, and I have never seen a new version since VB4 that did not implement something that I had previously done in one of my add-ins and it is no longer needed in a new version.

Sometimes, the way Microsoft implements it, you can find a way to do more than they have done it, and with greater functionality. You are not much of a programmer, if you can look at functionality and not improve on it, or look at a medium to large block of code and not be able to improve, reorganize, or make it be more efficient, etc.

Another challenge is to look at the new IDE and see if you can find something that is useful that MS has not implemented. If you are an application developer and you write add-ins as I do, you have an advantage over Microsoft in that you are using the IDE every minute of everyday and you constantly run into tasks that are repetitive and that just say, "automate me."

Finally, there is the challenge of finding out what has changed in the automation or extensibility model of the new release that breaks your add-ins. It's not usually hard to find out what is broken, the real challenge is to find out how to fix it.

That is the case with menus in add-ins in VS2005. Microsoft created a trimmed down version of Microsoft Office CommandBars. At first you think, "this is neat." At a second look, you find there is no free lunch. The cost here is that the command bars and their associated events do not work exactly the same as the MS Office counterpart. Especially is this true with respect to event handlers for the menus. I thought I would never get them working, and said, "nothing is this hard!" And actually it isn't; all you have to do is discover what the one way that it will work is.

I finally did and have posted an article on KnowDotNet so that you hopefully won't have the agony that I experienced. The article is at http://www.knowdotnet.com/articles/nestedmenusinvs2005.html.

I hope you will find it helpful.

2 Comments:

At 2:06 PM, Blogger Les Smith said...

To my knowledge, which is limited lately on ASP.NET, I don't think you can sort on a paged grid. I normally provided both, but the user had to turn off paging to sort. I always give the option to turn off paging and then they can sort.

 
At 11:34 AM, Blogger g-ben said...

Actually this is a comment about installing AddIns. I actually found a much easier way than updating your .AddIn file. I install all of our addins to C:\Program Files\My Company\Visual Studio AddIns

and then add a registry entry which tells visual studio to look in that directory for the addins.

Then your "Assembly" tag can just have the naked name of the assembly because VS 2005 will attempt to load the assembly from the directory where the .AddIn file is found.
All you have to do is add a registry entry with the name of your installtion directory to HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\AutomationOptions\LookInFolders

For instance, if you are using a setup project to install it, just add HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\AutomationOptions\LookInFolders\[TARGETDIR]
with an empty value.

 

Post a Comment

<< Home